<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8"/>
        <title>EasyUI&nbsp;Demo&nbsp;-&nbsp;Draggable</title>
        <link rel="shortcut icon" href="../../assets/image/favicon.ico"/>
        <script type="text/javascript" src="../../assets/js/common.js"></script>
        <link rel="stylesheet" type="text/css" href="../../assets/libs/easyui/themes/default/easyui.css">
        <link rel="stylesheet" type="text/css" href="../../assets/libs/easyui/themes/icon.css">
        <script type="text/javascript" src="../../assets/libs/easyui/jquery.min.js"></script>
        <script type="text/javascript" src="../../assets/libs/easyui/jquery.easyui.min.js"></script>
    </head>
    <body>
        <h1>Draggable&nbsp;-&nbsp;Base&nbsp;基础组件</h1>
        <fieldset>
            <legend>使用案例</legend>
            <p>通过标签创建一个可拖动的元素。</p>
            <div id="dd" class="easyui-draggable" data-options="handle:'#title1'" style="width:100px;height:100px;">
                <div id="title1" style="background:#ccc;">通过标签创建一个可拖动的元素</div>
            </div>
            <p>使用Javascript创建一个可拖动的元素。</p>
            <div id="dd1" style="width:100px;height:100px;">
                <div id="title2" style="background:#ccc;">使用Javascript创建一个可拖动的元素</div>
            </div>
        </fieldset>
    </body>
    <script type="text/javascript">
        $('#dd1').draggable({
            handle: '#title2',
            revert: true,
            delay: 1000,
            onBeforeDrag: function(e) {
                console.log("拖动前：", e);
            },
            onStartDrag: function(e) {
                console.log("开始拖动：", e);
            },
            onDrag: function(e) {
                console.log("拖动中：", e);
            },
            onStopDrag: function(e) {
                console.log("拖动停止：", e);
            },
            onEndDrag: function(e) {
                console.log("拖动停止（在onStopDrag之前）：", e);
            }
        });
    </script>
</html>